// hyb_yl/huanzhe/pages/patient_manage/patient_manage.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    zimu: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
    serchList: [{
      description: 111,
      count: "111"
    }],
    keyword:"",
    openid_list:[],
    list:[],
    zid:"",
    type:"",
  },
  zimu_btn: function (e) {
    var zimu = e.currentTarget.dataset.cont
    console.log(zimu)
    this.setData({
      toView: zimu
    })
  },
  serchinput: function (e) {
    console.log(e)
  },
  more_btn:function(e){
    console.log(e)
    this.setData({
      show:!this.data.show
    })
  },
  check_list:function(e){
    console.log(e);
    var that = this;
    var id = e.currentTarget.dataset.id;
    var index = e.currentTarget.dataset.index;
    var openid = e.currentTarget.dataset.openid;
    var zid = that.data.zid;
    var openid_list = that.data.openid_list;
    var user_list=this.data.list;
    for(var i=0;i<openid_list.length;i++)
    {
      if(openid_list[i] == openid)
      {
        openid_list.slice(i,1);
      }
    }
    if(openid_list.indexOf(openid) < 0)
    {
      openid_list.push(openid)
    }
    
    that.setData({
      list:user_list,
      openid_list:openid_list
    })
  },
  sure:function(){
    var that = this;
    var zid = that.data.zid;
    var openid_list = that.data.openid_list;
    openid_list = JSON.stringify(openid_list)
    var type = that.data.type;
    app.util.request({
      'url':"entry/wxapp/follow.set_fenzu",
      data:{
        openid:openid_list,
        zid:zid,
        type:type
      },
      success:function(res){
        wx.navigateBack({})
      }
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    that.setData({
      zid:options.zid,
      type:options.type
    })
    that.getUser();
  },
  getUser:function(){
    var that = this;
    app.util.request({
      'url':"entry/wxapp/follow.all_qzuser",
      data:{
        zid:that.data.zid,
        type:that.data.type,
        keyword:that.data.keyword,
      },
      success:function(res)
      {
        that.setData({
          list:res.data
        })
        console.log(that.data.list)
      }
    })
  },
  changekeyword:function(e){
    this.setData({
      keyword:e.detail.value,
      
    })
    
  },
  search:function(){
    this.getUser();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})